Allow client retry on a redirect of an upgrade check.
authorRobert Lipe <robertlipe@gpsbabel.org>
Mon, 24 Aug 2020 06:30:48 +0000 (01:30 -0500)
committerRobert Lipe <robertlipe@gpsbabel.org>
Mon, 24 Aug 2020 06:30:48 +0000 (01:30 -0500)
Not in this CL, server side change to NOT force an http->https upgrade
on this one URL.

gui/upgrade.cc

index 2c0eed1e10d5312fe6613c0d57d39e154fd0c51b..4f6c2c1c8ab6d4fd1dc7b277c1f2d6e0de21537d 100644 (file)
@@ -113,6 +113,11 @@ UpgradeCheck::updateStatus UpgradeCheck::checkForUpgrade(
           this, SLOT(httpRequestFinished(QNetworkReply*)));
 
   QNetworkRequest request = QNetworkRequest(upgradeUrl_);
+
+  // In Qt 5.6 and later, it can reissue with a redirect. With this in
+  // place, we don't see the 301 redirect, but the server has to issue
+  // one for the thousands of older clients out there.
+  request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
   request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
   request.setRawHeader("Accept-Encoding","identity");
 
@@ -171,10 +176,10 @@ UpgradeCheck::updateStatus UpgradeCheck::getStatus()
 }
 
 // GPSBabel version numbers throughout the code mostly predate QVersionNumber
-// and are stored as strings. They may be of the form "1.6.0-beta20200413" 
+// and are stored as strings. They may be of the form "1.6.0-beta20200413"
 // which, if sorted as a string, will be after "1.6.0" which is bad. Use
-// this function to sort that out. (See what I did there? Bwaaaahah!) 
-bool UpgradeCheck::suggestUpgrade(const QString& from, const QString& to) 
+// this function to sort that out. (See what I did there? Bwaaaahah!)
+bool UpgradeCheck::suggestUpgrade(const QString& from, const QString& to)
 {
   int fromIndex = 0;
   int toIndex = 0;
@@ -186,7 +191,7 @@ bool UpgradeCheck::suggestUpgrade(const QString& from, const QString& to)
   if (fromVersion < toVersion) {
     return true;
   }
-  // Just look for the presence of stuff (not even the contents) of the 
+  // Just look for the presence of stuff (not even the contents) of the
   // string. Shorter string (no "-betaXXX" wins)
   if (fromVersion == toVersion) {
     if (from.length() - fromIndex > to.length() - toIndex) {
@@ -195,7 +200,7 @@ bool UpgradeCheck::suggestUpgrade(const QString& from, const QString& to)
   }
   return false;
 }
-// Some day when we have Gunit or equiv, add unit tests for: 
+// Some day when we have Gunit or equiv, add unit tests for:
 //suggestUpgrade(updateVersion, currentVersion_);
 //suggestUpgrade("1.6.0-beta20190413", "1.6.0");
 //suggestUpgrade("1.6.0", "1.6.0-beta20190413");